package cn.edu.zut.hhr.utils;

import javafx.beans.binding.ObjectExpression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.Set;

/**
 * @author HHR
 * @date 2021/6/17
 */
@Component
public class RedisUtil {

    @Resource(name = "redisTemplate")
    private RedisTemplate<String,Object> redisTemplate;
    @Resource(name = "mDPasswordEncoder")
    PasswordEncoder passwordEncoder;

    public RedisUtil(RedisTemplate<String, Object> redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    public void sSet(String key, Object[] val){
        redisTemplate.opsForSet().add(key,val);
    }

    public Set sMembers(String key){
        return redisTemplate.opsForSet().members(key);
    }

    public void del(String key){
        redisTemplate.delete(key);
    }

    public RedisTemplate getRedisTemplate() {
        return redisTemplate;
    }

    public void setRedisTemplate(RedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }
}
